package com.biao.mall.product.web;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * 测试controller
 */
@RestController
public class CacheTestController {
    @Cacheable(value = "cache-test", key = "'spring-cache-cacheT1'")
    @GetMapping(value = "/cache1")
    public String cacheT1() {
        System.out.println("访问");
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        return list.toString();
    }

    @CacheEvict(value = "cache-test", key = "'spring-cache-cacheT1'")
    @GetMapping("/update")
    public String update(){
        return "update";
    }
}
